<template>
  <div>
    <FilterTable
      ref="salesMaterialsTable"
      :columns="salesMaterialsColumns"
      :dataSource="salesMaterialsList"
      :isToperInfo="false"
      :isColumnFilter="false"
      :isMemoryPagination="true"
      :height="400"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.salesMaterialsColumns = columns)"
    ></FilterTable>
  </div>
</template>

<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'Salesmaterials',
  mixins: [dictionary],
  props: ['vehicleDetailsVin', 'list', 'resetTable'],
  data() {
    this.BaseTable = null;
    return {
      salesMaterialsColumns: this.createSalesMaterialsColumns(),
      salesMaterialsList: []
    };
  },
  watch: {
    list(val) {
      this.insertRecords(val);
    },
    resetTable(val) {
      if (val) {
        // this.BaseTable.RESET_TABLE_DATA();
      }
    }
  },
  mounted() {
    this.BaseTable = this.$refs.salesMaterialsTable.$refs.pageTable;
    if (!this.resetTable) {
      this.insertRecords(this.list);
    }
  },
  created() {
    // this.dmsFunc = {dmsFuncId:35100010};
    // this.protectRepairFun(this.vehicleDetailsVin);
  },
  methods: {
    createSalesMaterialsColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '仓库代码',
          dataIndex: 'STORAGE_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '仓库名称',
          dataIndex: 'STORAGE_NAME',
          width: 150,
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件代码',
          dataIndex: 'PART_NO',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件名称',
          dataIndex: 'PART_NAME',
          width: 150,
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售数量',
          dataIndex: 'PART_QUANTITY',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '成本价',
          dataIndex: 'PART_COST_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '备件销售金额',
          dataIndex: 'PART_SALES_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '折让金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '折扣率',
          dataIndex: 'DISCOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '实收金额',
          dataIndex: 'REAL_RECEIVE_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        }
        // {
        //   title: '不可打折',
        //   dataIndex: 'IS_DISCOUNT',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'checkbox',
        //   filterItems: this.createDictList('1004'),
        //   render: props => {
        //     return <span>{this.createDictText(props.row.IS_DISCOUNT, '1004')}</span>;
        //   }
        // }
      ];
    },
    orderListChangeHandle(val) {},
    insertRecords(list) {
      this.salesMaterialsList = list;
      // this.BaseTable.EXECUTE_INSERT(list);
    }
  }
};
</script>

<style lang="less">
.custom-wrap {
  height: calc(100vh - 145px);
  // position: relative;
}
</style>
